setParent?

I've found in some cases (a tab within a tab), it is necessary to call setParent on the child tabs in order for things to render correctly. This begs the question: should I be calling setParent with all my controls that are on tabs? Anytime I use the "inside" constraint? When should I use setParent?

Here is some example code, if you want to play around with it. Without the call to setParent, the inner tabs do not get displayed.
 

DB box
DBE outerTab
DBE innerXTab
DBE innerYTab
DBE innerZTab
 
box = create("Test")
 
void outerTabSelected(DBE outerTab) {
    int i = get(outerTab)
        if (i == 0) {
                show(innerXTab)
        }
        else {
                hide(innerXTab)
        }
        if (i == 1) {
                show(innerYTab)
        }
        else {
                hide(innerYTab)
        }
        if (i == 2) {
                show(innerZTab)
        }
        else {
                hide(innerZTab)
        }
}
string outerItems[] = {"X", "Y", "Z"}
outerTab = tab(box, outerItems, 300, 400, outerTabSelected)
 
void innerXTabSelected(DBE innerXTab) {
}
string innerXItems[] = {"x.1", "x.2", "x.3"}
innerXTab = tab(box, innerXItems, 300, 400, innerXTabSelected)
setParent(innerXTab, outerTab)
 
void innerYTabSelected(DBE innerYTab) {
}
string innerYItems[] = {"y.1", "y.2", "y.3"}
innerYTab = tab(box, innerYItems, 300, 400, innerYTabSelected)
setParent(innerYTab, outerTab)
 
void innerZTabSelected(DBE innerZTab) {
}
string innerZItems[] = {"z.1", "z.2", "z.3"}
innerZTab = tab(box, innerZItems, 300, 400, innerZTabSelected)
setParent(innerZTab, outerTab)
 
outerTab->"top"->"form"
outerTab->"left"->"form"
outerTab->"right"->"form"
outerTab->"bottom"->"form"
 
innerXTab->"top"->"inside"->outerTab
innerXTab->"left"->"inside"->outerTab
innerXTab->"right"->"inside"->outerTab
innerXTab->"bottom"->"inside"->outerTab
 
innerYTab->"top"->"inside"->outerTab
innerYTab->"left"->"inside"->outerTab
innerYTab->"right"->"inside"->outerTab
innerYTab->"bottom"->"inside"->outerTab
 
innerZTab->"top"->"inside"->outerTab
innerZTab->"left"->"inside"->outerTab
innerZTab->"right"->"inside"->outerTab
innerZTab->"bottom"->"inside"->outerTab
 
show(box)

Thursday1036PM - Tue Jun 21 16:03:09 EDT 2011

Re: setParent?
Mathias Mamsch - Wed Jun 22 03:22:43 EDT 2011

Hmm ... is there any real advantage of using "inside" positioning? I would just position them below each other, then you don't need to use setParent ... Regards, Mathias
 

...
outerTab->"top"->"form"
outerTab->"left"->"form"
outerTab->"right"->"form"
 
innerXTab->"top"->"flush"->outerTab
innerXTab->"left"->"form"
innerXTab->"right"->"form"
 
innerYTab->"top"->"flush"->outerTab
innerYTab->"left"->"form"
innerYTab->"right"->"form"
 
innerZTab->"top"->"flush"->outerTab
innerZTab->"left"->"form"
innerZTab->"right"->"form"
 
DBE xx = label (box, "Hello")
xx->"top"->"spaced"->innerXTab
xx->"left"->"form"

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS